package demoMod.invincibleOne.powers;

import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.localization.PowerStrings;
import com.megacrit.cardcrawl.powers.AbstractPower;
import demoMod.invincibleOne.InvincibleOneMod;

public class InvinciblePower2 extends AbstractPower {
    public static final String POWER_ID = InvincibleOneMod.makeID("InvinciblePower2");
    private static final PowerStrings powerStrings = CardCrawlGame.languagePack.getPowerStrings("Invincible");
    public static final String NAME = powerStrings.NAME;
    public static final String[] DESCRIPTIONS = powerStrings.DESCRIPTIONS;
    private int maxAmt;

    public InvinciblePower2(AbstractCreature owner, int amount) {
        this.name = NAME;
        this.ID = POWER_ID;
        this.owner = owner;
        this.amount = amount;
        this.maxAmt = amount;
        updateDescription();
        loadRegion("heartDef");
        this.priority = 99;
    }

    public int onAttackedToChangeDamage(DamageInfo info, int damageAmount) {
        if (damageAmount > this.amount)
            damageAmount = this.amount;
        this.amount -= damageAmount;
        if (this.amount < 0)
            this.amount = 0;
        updateDescription();
        return damageAmount;
    }

    public void atStartOfTurn() {
        this.amount = this.maxAmt;
        updateDescription();
    }

    public void updateDescription() {
        if (this.amount <= 0) {
            this.description = DESCRIPTIONS[2];
        } else {
            this.description = DESCRIPTIONS[0] + this.amount + DESCRIPTIONS[1];
        }
    }

    @Override
    public void stackPower(int stackAmount) {
    }
}
